<template>
  <!-- 技术趋势路线图 -->
  <div>
    <div class="timeline-box chart">
      <div v-for="(item, index) in list" :key="index" class="block" >
        <h4>{{item && item['title']}}</h4>
        <template v-if="item&&item['children']">
          <ul class="">
            <li v-for="(citem, cindex) in item.children" :key="cindex" class="ellipsis">{{citem}}</li>
          </ul>
        </template>
        <i class="circle"></i>
        <div class="line"></div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name:"JSQ",
  props: {
    chartsData: {
      type: Array
    },
  },
  data() {
    return {
      list: [],
    };
  },
  watch:{
    chartsData(val){
      this.list = []
      this.chartsData.map((item,index) => {
        this.list.push(item)
      })
    }
  },
  mounted() {
      this.list = []
      this.chartsData.map((item,index) => {
        this.list.push(item)
      })
  },
};
</script>
<style lang="scss" scoped>
.timeline-box {
  height: 500px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 10px;
  margin-bottom: 10px;
  box-sizing: border-box;
  overflow-x: auto;
  .block {
    position: relative;
    flex: 1;
    min-width: 200px;
    text-align: center;
    &:nth-of-type(2n) {
      h4 {
        top: calc(50% + 40px);
        margin-top: 0;
      }
      ul {
        top: auto;
        bottom: calc(50% + 20px);

      }
    }
    &:first-of-type {
      .line {
        border-top-left-radius: 10px;
        border-bottom-left-radius: 10px;
      }
    }
    &:last-of-type {
      .line {
        border-top-right-radius: 10px;
        border-bottom-right-radius: 10px;
      }
    }
    h4 {
      position: absolute;
      top: calc(50% - 40px);
      width: 100%;
      line-height: 1;
      text-align: center;
      font-size: 14px;
      font-weight: bold;
    }
    ul {
      position: absolute;
      top: calc(50% + 20px);
      width: 100%;
      text-align: center;
      li {
        display: block;
        width: 100%;
        line-height: 20px;
        font-size: 12px;
      }
    }
    .circle {
      position: absolute;
      top: 50%;
      left: 50%;
      width: 16px;
      height: 16px;
      margin-top: -8px;
      margin-left: -8px;
      border-radius: 50%;
      background-color: #EE6666;
    }
    .line {
      position: absolute;
      top: 50%;
      left: 10px;
      width: 100%;
      height: 8px;
      margin-top: -4px;
      background-color: #EE6666;
    }
  }
}
</style>